public class Test {
    public static void main(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.addLast(11);
        mySingleList.addLast(21);
        mySingleList.addLast(31);
        mySingleList.addLast(41);
        mySingleList.display();
        System.out.println();
        MySingleList mySingleList2 = new MySingleList();
        mySingleList2.addLast(8);
        mySingleList2.addLast(15);
        mySingleList2.addLast(25);
        mySingleList2.addLast(30);
        mySingleList2.display();
        System.out.println("===========");
        MySingleList.ListNode ret=
                mergeTwoLists(mySingleList.head,mySingleList2.head);
        mySingleList.display(ret);
    }
    public static void main2(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.addLast(1);
        mySingleList.addLast(2);
        mySingleList.addLast(3);
        mySingleList.addLast(4);
        mySingleList.display();
        System.out.println("==========");
        /*MySingleList.ListNode ret=mySingleList.reverseList();
        mySingleList.display(ret);*/
        MySingleList.ListNode ret=mySingleList.findKthToTail(3);
        System.out.println(ret.val);
    }
    //合并两个有序链表
    public static MySingleList.ListNode mergeTwoLists
    (MySingleList.ListNode head1, MySingleList.ListNode head2){
        MySingleList.ListNode newHead=new MySingleList.ListNode(0);
        MySingleList.ListNode tmp=newHead;
        while(head1!=null&&head2!=null) {
            if (head1.val < head2.val) {
                tmp.next = head1;
                head1 = head1.next;
                tmp = tmp.next;
            } else {
                tmp.next = head2;
                head2 = head2.next;
                tmp = tmp.next;
            }
        }
        if(head1!=null){
            tmp.next=head1;
        }
        if(head2!=null){
            tmp.next=head2;
        }
        return newHead.next;
    }
    public static void main1(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.createLink();
        mySingleList.display();
        System.out.println();
        /*System.out.println();
        System.out.println("------------------");
        mySingleList.display();
        boolean a = mySingleList.contains(100);
        System.out.println(a);
        System.out.println(mySingleList.size());
        //mySingleList.addFirst(3);
        mySingleList.display();
        System.out.println();
        System.out.println("===========");
        mySingleList.addLast(59);
        mySingleList.addLast(59);
        mySingleList.addLast(59);*/
//        System.out.println();
//        mySingleList.addIndex(1,1);
//        mySingleList.display();
//        mySingleList.remove(23);
//        mySingleList.display();
        mySingleList.addFirst(1);
        mySingleList.addFirst(1);
        mySingleList.addFirst(1);
        mySingleList.addFirst(1);
        mySingleList.addFirst(1);
        mySingleList.addFirst(1);
        mySingleList.addFirst(2);
        mySingleList.addFirst(5);
        mySingleList.removeAllKey(1);
        mySingleList.display();
        mySingleList.clear();
        mySingleList.display();
        mySingleList.addIndex(99,0);
    }
}
